package com.bookpavilion.sms.listen;

import com.bookpavilion.sms.utils.SmsUtil;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "sms")
public class SmsListener {
    @Autowired
    private SmsUtil smsUtil;

    @RabbitHandler
    public void sendSms(Map<String,String> mes){
        try {
            smsUtil.sendSms(mes.get("mobile"),mes.get("code"));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
